package com.cuit.blogsystem.mapper;

import com.cuit.blogsystem.DTO.TextPageQueryDTO;
import com.cuit.blogsystem.DTO.TypePageQueryDTO;
import com.cuit.blogsystem.Result.PageResult;
import com.cuit.blogsystem.VO.TextVO;
import com.cuit.blogsystem.VO.TypeVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TextMapper {
    /**
     * 文章分页查询
     */
    Page<TextVO> pageQuery(TextPageQueryDTO textPageQueryDTO);
    /**
     * 删除文章下的评论
     */
    @Delete("delete from comment where text_id = #{textId}")
    void deleteComment(Long textId);

    /**
     * 查询单篇文章
     */
    @Select("select id, user_id, username, title, content, type, create_time from text where id = #{id}")
    TextVO findById(Long id);

    /**
     * 查询所有类型
     * @return
     */
    @Select("select type_name from type")
    List<String> listType();

    Page<TypeVO> typePageQuery(TypePageQueryDTO typePageQueryDTO);
}
